package com.dataconver.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 数据同步配置属性类
 * 使用Spring Boot的@ConfigurationProperties自动绑定配置文件
 */
@Component
@ConfigurationProperties(prefix = "sync")
public class DataSyncProperties {
    
    private String cron = "0 0 8 * * ?";
    private int batchSize = 1000;
    private int maxRetries = 3;
    private int retryDelay = 5000;
    
    private Scheduler scheduler = new Scheduler();
    private Map<String, TableConfig> table;
    
    // Getters and Setters
    public String getCron() {
        return cron;
    }
    
    public void setCron(String cron) {
        this.cron = cron;
    }
    
    public int getBatchSize() {
        return batchSize;
    }
    
    public void setBatchSize(int batchSize) {
        this.batchSize = batchSize;
    }
    
    public int getMaxRetries() {
        return maxRetries;
    }
    
    public void setMaxRetries(int maxRetries) {
        this.maxRetries = maxRetries;
    }
    
    public int getRetryDelay() {
        return retryDelay;
    }
    
    public void setRetryDelay(int retryDelay) {
        this.retryDelay = retryDelay;
    }
    
    public Scheduler getScheduler() {
        return scheduler;
    }
    
    public void setScheduler(Scheduler scheduler) {
        this.scheduler = scheduler;
    }
    
    public Map<String, TableConfig> getTable() {
        return table;
    }
    
    public void setTable(Map<String, TableConfig> table) {
        this.table = table;
    }
    
    /**
     * 调度器配置
     */
    public static class Scheduler {
        private boolean enabled = true;
        private boolean autoStart = true;
        private boolean manualSync = true;
        
        public boolean isEnabled() {
            return enabled;
        }
        
        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
        
        public boolean isAutoStart() {
            return autoStart;
        }
        
        public void setAutoStart(boolean autoStart) {
            this.autoStart = autoStart;
        }
        
        public boolean isManualSync() {
            return manualSync;
        }
        
        public void setManualSync(boolean manualSync) {
            this.manualSync = manualSync;
        }
    }
    
    /**
     * 表配置
     */
    public static class TableConfig {
        private boolean enabled = true;
        private String source;
        private String key;
        private String strategy;
        private String timestamp;
        private Map<String, String> columnMapping;
        
        public boolean isEnabled() {
            return enabled;
        }
        
        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
        
        public String getSource() {
            return source;
        }
        
        public void setSource(String source) {
            this.source = source;
        }
        
        public String getKey() {
            return key;
        }
        
        public void setKey(String key) {
            this.key = key;
        }
        
        public String getStrategy() {
            return strategy;
        }
        
        public void setStrategy(String strategy) {
            this.strategy = strategy;
        }
        
        public String getTimestamp() {
            return timestamp;
        }
        
        public void setTimestamp(String timestamp) {
            this.timestamp = timestamp;
        }
        
        public Map<String, String> getColumnMapping() {
            return columnMapping;
        }
        
        public void setColumnMapping(Map<String, String> columnMapping) {
            this.columnMapping = columnMapping;
        }
    }
}
